Skip to content

fix: assign receive-loop attributes before spawning recv task#102

Merged
PsiACE merged 2 commits into
agentclientprotocol:mainfrom
SAY-5:fix-connection-init-order
May 24, 2026
Merged

fix: assign receive-loop attributes before spawning recv task#102
PsiACE merged 2 commits into
agentclientprotocol:mainfrom
SAY-5:fix-connection-init-order

Conversation

@SAY-5
Copy link
Copy Markdown
Contributor

@SAY-5 SAY-5 commented May 21, 2026

Fixes #97. Connection.__init__ spawns the receive task before assigning self._receive_timeout, so under asyncio.eager_task_factory the loop runs synchronously through asyncio.wait_for(self._reader.readline(), timeout=self._receive_timeout) and raises AttributeError, tearing the connection down before __init__ returns. Moved _observers and _receive_timeout above the _tasks.create(_receive_loop(), ...) call and added a regression test that installs the eager task factory.

@PsiACE
Copy link
Copy Markdown
Member

PsiACE commented May 24, 2026

thanks, lgtm

@PsiACE PsiACE merged commit 7acca14 into agentclientprotocol:main May 24, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Connection.__init__ ordering bug: _receive_timeout set after recv task is spawned (breaks under asyncio.eager_task_factory)

2 participants